﻿using System;
using System.Collections;

namespace ConsoleApp3
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] nums = { 1, 4, 5, 6,4, 8, 7 };
            //输出数组
            DisplayArray(nums);
            //数组倒序
            ArrayReverse(nums);
            //数组输出,观察数组变化
            DisplayArray(nums);
            //数组加一
            AddOne(nums);
            //数组输出，观察变化
            DisplayArray(nums);
            //重载将数组加一
            AddOne(ref nums);
            //数组输出，观察变化
            DisplayArray(nums);
            
            Console.ReadKey();
        }  
        //将数组倒序
        static void ArrayReverse(int[] nums)
        {
            for (int i = 0; i <= (nums.Length - 1) / 2; i++)
            //交换数组
            {
                int temp = nums[i];
                nums[i] = nums[nums.Length - 1 - i];
                nums[nums.Length - 1 - i] = temp;
            }
        }
        //重载将数组每个数加一
        static void AddOne( ref int[] nums)
        {
            for (int i = 0; i < nums.Length; i++)
                nums[i] += 1;
        }
        //输出数组
        static void DisplayArray(int []nums)
        {
            foreach (int num in nums)
                Console.Write(num + " ");
            Console.WriteLine();
        }
        //将数组每个数加一
        static  void AddOne(int []nums)
        {
            for (int i = 0; i < nums.Length; i++)
                nums[i] += 1;
        }
        
    }
}
